import axios from '~/plugins/axios';

import * as types from '../../mutation-types/sales-category/index';

export const salesCategoryList = function({commit, state}, preload) {
    axios.get(process.env.baseUrl + '/dicttype/list?typeId=7', {
        params: preload || {}
    })
        .then(function(response) {
            if (!response) {
                return
            }
            if (response.data && response.data.data) {
                commit(types.SALES_CATEGORYLIST, {
                    salesCategoryList: response.data.data
                });
                commit(types.SALES_CATEGORYLIST_CURRENTPAGE, {
                    currentPage: response.data.currentPage
                });
                commit(types.SALES_CATEGORYLIST_TOTALCOUNT, {
                    totalCount: response.data.totalCount
                });
            }
        })
};

export const delSalesCategory = function({commit, state}, preload) {
    commit(types.SALES_CATEGORYLIST_DEL, {
        index: preload
    });
};

export const saveSalesCategory = function({commit, state}, preload) {

    if (preload.id) {
        //去调用编辑接口
    } else {
        //去调用添加接口
    }

};